﻿using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using Secured3d.Auto.Utils;

namespace Secured3d.Auto.Helpers
{
    public class TempEmail
    {
        private IWebDriver driver;

        public TempEmail()
        {
            driver = new FirefoxDriver();
        }

        public string GetTempEmail()
        {
            driver.Navigate().GoToUrl("http://www.fakeinbox.com/");

            try
            {
                var newEmailButton = driver.FindElement(By.CssSelector("input[name=\"getemail\"]"));
                newEmailButton.WaitUntilVisible().Click();

                var emailField = driver.FindElement(By.CssSelector(".t12l_address_input"));
                return emailField.WaitUntilVisible().GetAttribute("value");
            }
            finally
            {
                driver.Quit();
            }
        }
    }
}
